home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / gfx / nsIDrawingSurface.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  7KB  |  168 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsIDrawingSurface_h___
  39. #define nsIDrawingSurface_h___
  40.  
  41. #include "nscore.h"
  42. #include "nsISupports.h"
  43.  
  44. // a memory area that can be rendered to
  45.  
  46. typedef struct
  47. {
  48.   PRUint32  mRedZeroMask;     //red color mask in zero position
  49.   PRUint32  mGreenZeroMask;   //green color mask in zero position
  50.   PRUint32  mBlueZeroMask;    //blue color mask in zero position
  51.   PRUint32  mAlphaZeroMask;   //alpha data mask in zero position
  52.   PRUint32  mRedMask;         //red color mask
  53.   PRUint32  mGreenMask;       //green color mask
  54.   PRUint32  mBlueMask;        //blue color mask
  55.   PRUint32  mAlphaMask;       //alpha data mask
  56.   PRUint8   mRedCount;        //number of red color bits
  57.   PRUint8   mGreenCount;      //number of green color bits
  58.   PRUint8   mBlueCount;       //number of blue color bits
  59.   PRUint8   mAlphaCount;      //number of alpha data bits
  60.   PRUint8   mRedShift;        //number to shift value into red position
  61.   PRUint8   mGreenShift;      //number to shift value into green position
  62.   PRUint8   mBlueShift;       //number to shift value into blue position
  63.   PRUint8   mAlphaShift;      //number to shift value into alpha position
  64. } nsPixelFormat;
  65.  
  66. #define RASWIDTH(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
  67.  
  68. #define NS_IDRAWING_SURFACE_IID   \
  69. { 0x61cc77e0, 0xcaac, 0x11d2, \
  70. { 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
  71.  
  72. class nsIDrawingSurface : public nsISupports
  73. {
  74. public:
  75.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAWING_SURFACE_IID)
  76.   /**
  77.    * Lock a rect of a drawing surface and return a
  78.    * pointer to the upper left hand corner of the
  79.    * bitmap.
  80.    * @param  aX x position of subrect of bitmap
  81.    * @param  aY y position of subrect of bitmap
  82.    * @param  aWidth width of subrect of bitmap
  83.    * @param  aHeight height of subrect of bitmap
  84.    * @param  aBits out parameter for upper left hand
  85.    *         corner of bitmap
  86.    * @param  aStride out parameter for number of bytes
  87.    *         to add to aBits to go from scanline to scanline
  88.    * @param  aWidthBytes out parameter for number of
  89.    *         bytes per line in aBits to process aWidth pixels
  90.    * @return error status
  91.    *
  92.    **/
  93.   NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
  94.                   void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
  95.                   PRUint32 aFlags) = 0;
  96.  
  97.   /**
  98.    * Unlock a rect of a drawing surface. must be preceded
  99.    * by a call to Lock(). Lock()/Unlock() pairs do not nest.
  100.    * @return error status
  101.    *
  102.    **/
  103.   NS_IMETHOD Unlock(void) = 0;
  104.  
  105.   /**
  106.    * Get the dimensions of a drawing surface
  107.    * @param  aWidth out parameter for width of drawing surface
  108.    * @param  aHeight out parameter for height of drawing surface
  109.    * @return error status
  110.    *
  111.    **/
  112.   NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight) = 0;
  113.  
  114.   /**
  115.    * Get the offscreen status of the drawing surface
  116.    * @param  aOffscreen out parameter for offscreen status of
  117.    *         drawing surface. if PR_TRUE, then modifying the
  118.    *         drawing surface does not immediately reflect the
  119.    *         changes on the output device
  120.    * @return error status
  121.    *
  122.    **/
  123.   NS_IMETHOD IsOffscreen(PRBool *aOffScreen) = 0;
  124.  
  125.   /**
  126.    * Get the pixel addressability status of the drawing surface
  127.    * @param  aAddressable out parameter for pixel addressability
  128.    *         status of drawing surface. if PR_TRUE, then the
  129.    *         drawing surface is optimized for pixel addressability
  130.    *         (i.e. the Lock() method has very low overhead). All
  131.    *         drawing surfaces support Lock()ing, but doing so on
  132.    *         drawing surfaces that do not return PR_TRUE here may
  133.    *         impose significant overhead.
  134.    * @return error status
  135.    *
  136.    **/
  137.   NS_IMETHOD IsPixelAddressable(PRBool *aAddressable) = 0;
  138.  
  139.   /**
  140.    * Get the pixel format of a drawing surface
  141.    * @param  aOffscreen out parameter filled in with pixel
  142.    *         format information.
  143.    * @return error status
  144.    *
  145.    **/
  146.   NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat) = 0;
  147. };
  148.  
  149. //when creating a drawing surface, you can use this
  150. //to tell the drawing surface that you anticipate
  151. //the need to get to the actual bits of the drawing
  152. //surface at some point during it's lifetime. typically
  153. //used when creating bitmaps to be operated on by the
  154. //nsIBlender implementations.
  155. #define NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS  0x0001
  156.  
  157. //flag to say that this drawing surface is shortlived,
  158. //which may affect how the OS allocates it. Used for
  159. //tiling, grouting etc.
  160. #define NS_CREATEDRAWINGSURFACE_SHORTLIVED        0x0002
  161.  
  162. //when locking a drawing surface, use these flags to
  163. //control how the data in the surface should be accessed
  164. #define NS_LOCK_SURFACE_READ_ONLY       0x0001
  165. #define NS_LOCK_SURFACE_WRITE_ONLY      0x0002
  166.  
  167. #endif  // nsIDrawingSurface_h___ 
  168.